package com.example.springscuritydemo.controller;

import com.example.springscuritydemo.Entity.User;
import com.example.springscuritydemo.annotation.Log;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName DempController
 * @Description TODO
 * @Author 吃麻椒的花酱
 * @Date 2022/4/13 14:30
 * @Version 1.0
 */
@RestController
@RequestMapping("/system")
public class DempController {

    @PreAuthorize("hasRole('admin')")
    @PostMapping("/admin")
    public Object admin(){
        return "admin";
    }

    @Log
    @PreAuthorize("principal.username.equals('admin')")
    @PostMapping("/save")
    public Object save()
    {
        System.out.println("执行了");
        return "save";
    }


    @PostMapping("/upload")
    public Object update(MultipartFile file) {

        return file.getOriginalFilename();
    }




}
